<template>
  <div>
    <h2>房号添加</h2>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td><span style="color: red">*</span>房型名称</td>
          <td>
            <input type="text" v-model="form.name" />
          </td>
        </tr>
        <tr>
          <td><span style="color: red">*</span>房号</td>
          <td><input type="text" v-model="form.fhao" /></td>
        </tr>

        <tr>
          <td>排序</td>
          <td>
            <input type="text" v-model="form.paixu" />
          </td>
        </tr>

        <tr>
          <td>备注</td>
          <td>
            <textarea v-model="form.beizhu"></textarea>
          </td>
        </tr>
        <tr>
          <td>状态</td>
          <td>
            <input
              type="radio"
              v-model="form.zhuangtai"
              name="zhuang"
              checked
            />上架
            <input
              type="radio"
              v-model="form.zhuangtai"
              name="zhuang"
              
            />下架
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <button @click="Add">添加</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { Extension } from "typescript";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();
const form = reactive({
  id: 0,
  name: "",
  fhao: "",
  paixu: "",
  beizhu: "",
  zhuangtai: "",
});
const Add=()=>{
    if(!form.name){
        alert("房型名称不能为空");
        return;
    }
    if(!form.fhao){
        alert("房号不能为空")
    }
    axios.post("https://localhost:7074/api/fanghao/Addhao",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
        }
        else{
            alert("添加失败");
        }
    })
   
}


</script>

<style scoped></style>
